const appInstance = getApp();
const BASE_URL = appInstance.globalData.baseUrl;
Page({
  data: {
    baseUrl: BASE_URL,
    partList: [{
        id: '1',
        active: false,
        text: '上衣服饰',
        img: '/assets/icons/part-01.png'
      },
      {
        id: '2',
        active: false,
        text: '头部饰品',
        img: '/assets/icons/part-02.png'
      },
      {
        id: '3',
        active: false,
        text: '鞋饰',
        img: '/assets/icons/part-03.png'
      },
      {
        id: '4',
        active: false,
        text: '腿部服饰',
        img: '/assets/icons/part-04.png'
      }
    ],
    goodsList: [{
        id: '1',
        image: BASE_URL + '/images/other/category-04.png'
      },
      {
        id: '2',
        image: BASE_URL + '/images/other/category-04.png'
      },
      {
        id: '3',
        image: BASE_URL + '/images/other/category-04.png'
      },
      {
        id: '4',
        image: BASE_URL + '/images/other/category-04.png'
      },
      {
        id: '4',
        image: BASE_URL + '/images/other/category-04.png'
      },
      {
        id: '4',
        image: BASE_URL + '/images/other/category-04.png'
      },
      {
        id: '4',
        image: BASE_URL + '/images/other/category-04.png'
      },
    ]
  },
  onLoad() {
    console.log(this.data.partList)
  },
  handlePart(e) {
    console.log(e)
    const {
      id
    } = e.currentTarget.dataset;
    const {
      partList
    } = this.data;
    const index = partList.findIndex(item => item.id === id);
    partList.forEach((item, i) => {
      item.active = (i === index);
    });
    this.setData({
      partList
    });
  }
})